package net.zjitc.service.impl;

import net.zjitc.common.ServiceResponse;
import net.zjitc.mapper.NoticeMapper;
import net.zjitc.pojo.Notice;
import net.zjitc.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * @AUTHOR zhj
 * @DATE 2019/3/28 14:56
 */
@Service
@Transactional
public class NoticeServiceImpl implements NoticeService {
    @Autowired
    NoticeMapper noticeMapper;


    @Override
    public List<Notice> findAll() {
        return noticeMapper.findAll();
    }

    @Override
    public Notice findById(int id) {
        return noticeMapper.findById(id);
    }

    @Override
    public int updateNotice(Notice notice) {
        return noticeMapper.updateById(notice);
    }

    @Override
    public ServiceResponse editNotice(Notice notice) {
        //业务在此处理
        int resultCount = noticeMapper.updateById(notice);
        if (resultCount>0){
            return ServiceResponse.createSuccssAndMessage("修改成功");
        }
        return ServiceResponse.createErrorMessage("修改失败");
    }
}
